package thread.yield;

public class YieldTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (int i = 0 ; i < 10 ; i++){
                if (i % 2 == 0){
                    Thread.yield();
                    System.out.println("让出CPU执行权");
                }
                System.out.println("正常运行");
            }
        });
        thread.start();
    }
}
